package bloomers

/**
* The User class holds all the user information and the seeds associated with the User
*
*/

class User {
    
    String email
    String password
    String firstName
    String lastName
    String gender
    String city
    String state
    String country
    String zipcode
  //  Date dateOfBirth
    
    String role = "user"
    
    def seedArr = new ArrayList()
    def locked = new Boolean(false)
    static def lockedList = new ArrayList<User>()

    static constraints = {
        firstName()
        lastName()
        email(email:true)
        password(blank:false, password:true)
        //dateOfBirth()
        role display:false
        role(inList:["admin", "user"])
        gender(inList:["M", "F"])
        city()
        state(inList:['AL', 'AK', 'AS', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'DC', 'FM', 'FL', 'GA', 'GU', 
        'HI', 'ID', 'IL', 'IN', 'IA', 'KS', 'KY', 'LA', 'ME', 'MH', 'MD', 'MA', 'MI', 'MN', 'MS', 'MO', 'MT', 'NE', 
        'NV', 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'MP', 'OH', 'OK', 'OR', 'PW', 'PA', 'PR', 'RI', 'SC', 'SD', 'TN', 
        'TX', 'UT', 'VT', 'VI', 'VA', 'WA', 'WV', 'WI', 'WY'])
        zipcode()
        country()
    }
    
    
    static transients = ['admin'] 
    
    /**
    * Checks to see if a User's is an admin - if true, updates the User's role to admin
    */
   
    boolean isAdmin(){ 
        return role == "admin"
    }
    
    
}
